
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
import random
class MainHandler(webapp.RequestHandler):
  def get(self):
    name = self.request.get('name')
    self.response.out.write('Hello ' + name)
    self.response.out.write("<a href= '/static/index.html'>My index.html</a>")

class DiceHandler(webapp.RequestHandler):
  def get(self):
    times = self.request.get('times')
    DICE_ROLLS = int(times)
 
                                                                                                          
        
    for roll_num in range(DICE_ROLLS): 
        dice_1 = random.randint   (1,6)                                                   
        dice_2 = random.randint(1, 6)
        self.response.out.write('Rolls:'+ str(dice_1) + ' ' + str(dice_2) + '<br>')

    self.response.out.write("Rolled the dice " + str(DICE_ROLLS) +  "    times")                      

    self.response.out.write('<br> Happy?')


class GoodbyeHandler(webapp.RequestHandler):
  def get(self):
    self.response.out.write('Goodbye app engine world!')

def main():
  application = webapp.WSGIApplication([('/hello.*', MainHandler),
                                        ('/goodbye.*', GoodbyeHandler),
                                        ('/dice.*', DiceHandler)],
                                       debug=True)
  run_wsgi_app(application)

if __name__ == '__main__':
  main()

